<?php
/**
 * Free Uch
 *
 * @category   FreeUch
 * @copyright  Copyright 2009 lordharrdlee(http://www.lordharrdlee.cn)
 * @author     lordharrdlee<lordharrdlee@gmail.com>
 * @version    $Id: Repaste.php 10 2010-01-14 10:31:01Z lordharrdlee $
 */
/**
 * Action_Repaste
 * @author     lordharrdlee<lordharrdlee@gmail.com>
 */
class Action_Repaste extends Action_Base
{
    protected $useModel = true;

    /**
     * @var Model_Repaste
     */
    protected $model;
    
    public function init() {
        if(!$this->isLogin()) {            
            $this->showall();
        }
    }

    public function index(){
        if ($this->SGLOBAL['member']['friendnum'] > 0) {            
            $this->showfriends();
        } else {
            $this->showme();
        }
        
    }

    public function showall() {
        $this->view->actives['all'] = 'class="active"';

        /*$this->model->addNew(
            array(
                'title_template'=>'asdfasdf',
                'title_data'=>'adfsadfsdf',
                'body_template'=>'198237912837',
                'body_data'=>'12390123',
                'type'=>'link',
                'typeid'=>'1',
                'dateline'=>$this->SGLOBAL['timestamp'],
                'authorid'=>$this->SGLOBAL['supe_uid'],
                'author'=>$this->SGLOBAL['supe_username'],
                'content'=>'asdfsdfsadfsdfasdfasdfasdf',
                'hasvote'=>0,
                'friend'=>0,
                'target_ids'=>''
            )
        );
        $this->model->addRepaste(array(
            'rpid'=>2,
            'uid'=>$this->SGLOBAL['supe_uid'],
            'username'=>$this->SGLOBAL['supe_username'],
            'friend'=>0,
            'target_ids'=>'',
            'time'=>$this->SGLOBAL['timestamp'],
        ));*/

        $data = $this->model->getListFriends(1);

        $this->display('list');
    }

    public function showme() {
        $this->view->actives['me'] = 'class="active"';

        $list = $this->model->getListByUid($this->SGLOBAL['supe_uid']);

        $this->display('list');
    }

    public function showfriends() {
        $this->view->actives['we'] = 'class="active"';

        if ($this->SGLOBAL['member']['friendnum'] == 0) {
            $this->showme();
            exit;
        }

        $list = $this->model->getListFriends($this->SGLOBAL['supe_uid']);

        $this->display('list');
    }

    public function add() {
        $this->view->actives['repaste'] = 'class="active"';
        $this->display('add');
    }
}